import http from "@/common/http.js"

export const geMallList = (params,callback)=>{ // 商城列表
	return new Promise((resolve,reject) =>{
		http.request({
			url: '/api/v1/mall/commodity/page',
			method:'GET',
			data: params,
			success: res => {
				resolve(res)
				callback && callback(res);
			},
			fail: res => {
				resolve(res)
				callback && callback(res);
			}
		})
	})
}

export const getMallDetails = (params,callback)=>{
	return new Promise((resolve,reject) =>{
		http.request({
			url: '/api/v1/mall/commodity/info',
			method:'GET',
			data: params,
			success: res => {
				resolve(res)
				callback && callback(res);
			},
			fail: res => {
				resolve(res)
				callback && callback(res);
			}
		})
	})
}

export const getAddressList = (params,callback)=>{ // 查询地址列表
	return new Promise((resolve,reject) =>{
		http.request({
			url: '/api/v1/mall/user/address/list',
			method:'GET',
			data: params,
			success: res => {
				resolve(res)
				callback && callback(res);
			},
			fail: res => {
				resolve(res)
				callback && callback(res);
			}
		})
	})
}

export const addAddress = (params,callback)=>{ // 新增收货地址
	return new Promise((resolve,reject) =>{
		http.request({
			url: '/api/v1/mall/user/address/save',
			method:'POST',
			data: params,
			success: res => {
				resolve(res)
				callback && callback(res);
			},
			fail: res => {
				resolve(res)
				callback && callback(res);
			}
		})
	})
}

export const integralPay = (params,callback)=>{ // 积分支付
	return new Promise((resolve,reject) =>{
		http.request({
			url: '/api/v1/mall/order/unifiedPay',
			method:'POST',
			data: params,
			success: res => {
				resolve(res)
				callback && callback(res);
			},
			fail: res => {
				resolve(res)
				callback && callback(res);
			}
		})
	})
}

export const getMerchatData = (params,callback)=>{ // 商户数据
	return new Promise((resolve,reject) =>{
		http.request({
			url: '/api/v1/getMerchantData',
			method:'POST',
			data: params,
			success: res => {
				resolve(res)
				callback && callback(res);
			},
			fail: res => {
				resolve(res)
				callback && callback(res);
			}
		})
	})
}

export const getUserDataStatistics = (params,callback)=>{ // 用户数据统计
	return new Promise((resolve,reject) =>{
		http.request({
			url: '/api/v1/getUserData/statistics',
			method:'POST',
			data: params,
			success: res => {
				resolve(res)
				callback && callback(res);
			},
			fail: res => {
				resolve(res)
				callback && callback(res);
			}
		})
	})
}

export const getTradeRanking = (params,callback)=>{ // 交易排行
	return new Promise((resolve,reject) =>{
		http.request({
			url: '/api/v1/getUserData/tradeRanking',
			method:'POST',
			data: params,
			success: res => {
				resolve(res)
				callback && callback(res);
			},
			fail: res => {
				resolve(res)
				callback && callback(res);
			}
		})
	})
}

export const getMallOrderList = (params,callback)=>{ //商城 订单列表
	return new Promise((resolve,reject) =>{
		http.request({
			url: '/api/v1/mall/order/list',
			method:'GET',
			data: params,
			success: res => {
				resolve(res)
				callback && callback(res);
			},
			fail: res => {
				resolve(res)
				callback && callback(res);
			}
		})
	})
}

export const addAlipay = (params,callback)=>{ //绑定支付宝
	return new Promise((resolve,reject) =>{
		http.request({
			url: '/api/v1/saveAlipayAccount',
			method:'POST',
			data: params,
			success: res => {
				resolve(res)
				callback && callback(res);
			},
			fail: res => {
				resolve(res)
				callback && callback(res);
			}
		})
	})
}

export const getLastedVersion = (params,callback)=>{ //获取app最新版本
	return new Promise((resolve,reject) =>{
		http.request({
			url: '/api/v1/version',
			method:'GET',
			data: params,
			success: res => {
				resolve(res)
				callback && callback(res);
			},
			fail: res => {
				resolve(res)
				callback && callback(res);
			}
		})
	})
}

export const getMemberRelation = (params,callback)=>{ 
	return new Promise((resolve,reject) =>{
		http.request({
			url: '/api/v1/getMemberRelation',
			method:'POST',
			data: params,
			success: res => {
				resolve(res)
				callback && callback(res);
			},
			fail: res => {
				resolve(res)
				callback && callback(res);
			}
		})
	})
}

export const getIntro = (params,callback)=>{ 
	return new Promise((resolve,reject) =>{
		http.request({
			url: '/api/v1/getAboutSn',
			method:'GET',
			data: params,
			success: res => {
				resolve(res)
				callback && callback(res);
			},
			fail: res => {
				resolve(res)
				callback && callback(res);
			}
		})
	})
}

export const wareUp = (params,callback)=>{ 
	return new Promise((resolve,reject) =>{
		http.request({
			url: '/api/v1/allocatedConfirm',
			method:'GET',
			data: params,
			success: res => {
				resolve(res)
				callback && callback(res);
			},
			fail: res => {
				resolve(res)
				callback && callback(res);
			}
		})
	})
}